# ifndef __Transliteration_H_
# define __Transliteration_H_

# include <string>
# include <list>

class CTransliterator {
	// Disable copy semantics.
	CTransliterator (const CTransliterator &);
	void operator = (const CTransliterator &);

  public:
	CTransliterator (const char * _pStart, const char * _pEnd);

	void Do (const char * _strIn, const char * _strInEnd, string_t & _strOut) const;

	const string_t & GetName () const {return m_strName;}
	WORD GetLangId () const {return m_wLangId;}

  private:
	// The node of the state machine;
	struct CNode {
		// Replacement string (in heap).
		string_t strReplacement;
		// Array of 256 next nodes (in heap).
		CNode * pNextNodes;

		CNode () : pNextNodes (NULL) {}
		~CNode () {delete [] pNextNodes;}
	};

	// The root table of the state machine shifts.
	CNode m_nodes [256];

	string_t m_strName;
	WORD m_wLangId;
};

class CTransliteration {
	// Disable copy semantics.
	CTransliteration (const CTransliteration &);
	void operator =  (const CTransliteration &);
	
  public:
	CTransliteration () : m_bLoaded (false) {}
	~CTransliteration ();
	
	void Load ();

	size_t GetNumOfTransliterators () const {return m_transliterators.size ();}
	const CTransliterator * GetTransliterator (size_t _cIndex) const {
		assert (_cIndex < m_transliterators.size ());
		if (_cIndex >= m_transliterators.size ())
			return NULL;
		return m_transliterators [_cIndex];
	}

  private:
	bool m_bLoaded;

    typedef std::vector<CTransliterator *> transliterators_t;
	transliterators_t m_transliterators;
};

extern CTransliteration g_Transliteration;

# endif // __Transliteration_H_